|
|
|
|
|
|
|
Many Visual Basic controls can display text. The main purpose of text boxes and labels is to display text, but many other controls use text as well. Command buttons, check boxes, and many others display text in a caption. Forms display text in a title bar. Even picture boxes can display text created with the Print method. |
|
|
|
|
|
|
|
|
A control's Font property determines how the control displays text. The Font property is actually an object that contains several properties of its own. The properties you can access in a Font object are Name, Size, Bold, Italic, StrikeThrough, Underline, and Weight. |
|
|
|
|
|
|
|
|
A Font object's Name property determines which typeface the control uses. You can find out what typefaces are available on a computer or printer at run time by examining the object's Fonts property. For example, the following code adds the names of the available screen fonts to a list control named ScreenList. |
|
|
|
 |
|
|
|
|
Dim i As Integer
For i = 0 To Screen.FontCount - 1
ScreenList.AddItem Screen.Fonts(i)
Next i |
|
|
|
|
|
|
|
|
Example program ListFont, shown in Figure 1.19, uses similar code to list the fonts available on your screen and printer. It compares the two lists and highlights fonts that appear in one list but not the other. |
|
|
|
|
|
|
|
|
If a control's font is not available, the font mapper picks a different font for you. This can happen, for example, if you write a program and then give it to other people to use |
|
|
|
|
|
|
|
|
Figure 1.19
Example program ListFont lists the
fonts available on the computer and printer. |
|
|
|
|
|